# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-wtf8
_pkgname=wtf8
pkgver=1.0.2
pkgrel=1
pkgdesc="An ocaml library that implements a WTF-8 encoder and decoder"
url="https://github.com/flowtype/ocaml-wtf8"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml aport
license="MIT"
depends="ocaml-runtime"
makedepends="dune ocaml ocaml-findlib opam"
options="!check"  # no tests provided
subpackages="$pkgname-dev"
source="https://github.com/flowtype/$pkgname/archive/v$pkgver/$pkgname-$pkgver.tar.gz"

build() {
	dune build @install
}

package() {
	mkdir -p "$pkgdir"/usr/lib/ocaml
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	# There's just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc

	# Remove annotation files and sources.
	cd "$pkgdir"/usr/lib/ocaml/$_pkgname
	rm -f *.cmt* *.ml

	chmod +x *.cmxs
}

dev() {
	default_dev

	depends="$pkgname=$pkgver-r$pkgrel"
	local sitelib="usr/lib/ocaml/$_pkgname"

	mkdir -p "$subpkgdir"/$sitelib

	cd "$pkgdir"/$sitelib
	mv *.cmx *.cmxa *.mli "$subpkgdir"/$sitelib/
}

sha512sums="3e7a65e0085a84648e4758faf6873a7b6d037d0e45ac6be3f545b0ab9676287a31b803d5ceb0d93f8f34b771dd80b7b8770af06227a2ebfc8e0a9f12d21a7215  ocaml-wtf8-1.0.2.tar.gz"
